<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>41.await函数</title>
</head>
<body>
<script>
  //定义一个promise对象
  let p =new Promise((resolve, reject) => {
    // resolve('成功的数据')
    reject('失败')
  })

  //await必须定义在async函数里面
  async function m1() {
    //使用try包裹，reject函数返回的失败数据就会走到catch分支
    try {
      //await  写在promise对象前面
      let result = await p
      console.log(result)
    }catch (e) {
      console.log(e)
    }
  }

  m1()


</script>
</body>
</html>